﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DataAccess;
using Entities;
using BusinessLogic;
using System.Data;

namespace TestMock1_G2
{
    [TestClass]
    public class UnitTest_Quy
    {
        [TestMethod]
        public void CheckBalanceTest()
        {
            AccountEntites ace = new AccountEntites();
            CardEntites cardE = new CardEntites();
            cardE.CardNo = "1234567891234561";
            ace.Balance = 54110000;
            DataTable expected = DataAccess.Data.ExeStoredWithParamToDataTable("ProAccountSelectByCardNo", "@CardNo", cardE.CardNo);
            DataTable actual;
            actual = AccountDA.GetBalance(cardE);
            Assert.IsTrue(CompareDataTables(expected, actual));
        }
        public static bool CompareDataTables(DataTable DT1, DataTable DT2)
        {
            if ((DT1 == null) && (DT2 == null))
            {
                return true;
            }
            else if ((DT1 != null) && (DT2 != null))
            {
                if (DT1.Rows.Count == DT2.Rows.Count)
                {
                    if (DT1.Columns.Count == DT2.Columns.Count)
                    {
                        for (int i = 0; i < DT1.Rows.Count; i++)
                        {
                            for (int j = 0; j < DT1.Columns.Count; j++)
                            {
                                if (DT1.Rows[i][j].ToString() != DT2.Rows[i][j].ToString())
                                    return false;
                            }
                        }
                        return true;
                    }
                    else
                        return false;
                }
                else
                    return false;
            }
            else
                return false;
        }
    }
}
